﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace Zero.UControl.Base.Helper.Base
{
    internal class DrawTextCommand : IDrawingCommand
    {
        public TextBlock? TextBlock { get; private set; }
        private readonly Canvas _canvas;
        private readonly Point _loc;
        private readonly string _txt;
        private readonly Brush _fg;
        private readonly double _size;

        public DrawTextCommand(Canvas c, Point l, string t, Brush f, double s)
        {
            _canvas = c;
            _loc = l;
            _txt = t;
            _fg = f;
            _size = s;
        }

        public void Execute()
        {
            TextBlock = new TextBlock { Text = _txt, Foreground = _fg, FontSize = _size };
            Canvas.SetLeft(TextBlock, _loc.X);
            Canvas.SetTop(TextBlock, _loc.Y);
            _canvas.Children.Add(TextBlock);
        }
        public void UnExecute()
        {
            if (TextBlock != null)
                _canvas.Children.Remove(TextBlock);
        }
    }

}
